package org.yoki.edu.common.protocol.radius.enums;

import lombok.Getter;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2017/12/14$ 16:13$
 */
public enum RadiusCodeEnum {

    /**
     * 1       Access-Request
     * 2       Access-Accept
     * 3       Access-Reject
     * 4       Accounting-Request
     * 5       Accounting-Response
     * 11       Access-Challenge
     * 12       Status-Server (experimental)
     * 13       Status-Client (experimental)
     * 255       Reserved
     */

    accessRequest(1),
    accessAccept(2),
    accessReject(3),

    accountingRequest(4),
    accountingResponse(5),

    accessChallenge(11),
    statusServer(12),
    statusClient(13),

    reserved(255);

    @Getter
    private Integer type;

    RadiusCodeEnum(Integer type) {
        this.type = type;
    }

    public static RadiusCodeEnum getByTypeCode(Integer type) {
        if (null == type) {
            return null;
        }
        RadiusCodeEnum[] enums = RadiusCodeEnum.values();
        for (RadiusCodeEnum radiusCodeEnum : enums) {
            if (radiusCodeEnum.getType().intValue() == type.intValue()) {
                return radiusCodeEnum;
            }
        }
        return null;
    }

}
